package com.hiyee.user.controller;

import com.hiyee.api.BaseController;
import com.hiyee.api.controller.user.AppUserControllerApi;
import com.hiyee.grace.result.ResponseJsonResult;
import com.hiyee.user.service.AppUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class AppUserController extends BaseController implements AppUserControllerApi {

    final static Logger logger = LoggerFactory.getLogger(AppUserController.class);

    @Autowired
    private AppUserService appUserService;

    @Override
    public ResponseJsonResult getList(String nickname, Integer status, Date start_date, Date end_date, Integer page, Integer page_size) {
        if(page == null) {
            page = DEFAULT_PAGE;
        }
        if(page_size == null) {
            page_size =  DEFAULT_PAGE_SIZE;
        }
        return ResponseJsonResult.success(appUserService.getList(nickname, status, start_date, end_date, page, page_size));
    }

    @Override
    public ResponseJsonResult get(String userId) {
        return ResponseJsonResult.success(appUserService.getById(userId));
    }

    @Override
    public ResponseJsonResult freeze(String userId) {
        return ResponseJsonResult.success(appUserService.freeze(userId));
    }
}
